package com.grass.p019lv.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.widget.AppCompatRatingBar;
import androidx.recyclerview.widget.RecyclerView;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.bean.VideoBean;
import com.androidx.p013lv.base.recycler.BaseRecyclerAdapter;
import com.androidx.p013lv.base.recycler.BaseRecyclerHolder;
import com.androidx.p013lv.base.utils.TimeUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.androidx.p013lv.player.view.ListVideoPlayer;

/* renamed from: com.grass.lv.adapter.AdapterRecommend */
public class AdapterRecommend extends BaseRecyclerAdapter<VideoBean, Holder> {
    private String domain;
    double height = ((double) (((UiUtils.getWindowWidth() - UiUtils.dp2px(20)) * 9) / 16));
    private int isPlay;
    ListVideoPlayer.PlayerVideoInterface playerVideoInterface;

    public AdapterRecommend(String str, ListVideoPlayer.PlayerVideoInterface playerVideoInterface2) {
        this.domain = str;
        this.playerVideoInterface = playerVideoInterface2;
    }

    public void setIsPlay(int i) {
        this.isPlay = i;
    }

    public void MyHolder(Holder holder, int i) {
        holder.setData((VideoBean) getDataInPosition(i), i, getItemViewType(i));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public int getItemViewType(int i) {
        return ((VideoBean) this.list.get(i)).getVideoId() == -1 ? 1 : 0;
    }

    public void onViewRecycled(Holder holder) {
        super.onViewRecycled((RecyclerView.ViewHolder) holder);
        ListVideoPlayer listVideoPlayer = holder.player;
        if (listVideoPlayer != null) {
            listVideoPlayer.onViewRecycled();
            listVideoPlayer.release();
        }
    }

    @Override // androidx.recyclerview.widget.RecyclerView.Adapter
    public Holder onCreateViewHolder(ViewGroup viewGroup, int i) {
        View view;
        if (i == 0) {
            view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_recommend, viewGroup, false);
        } else {
            view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_recommend_at, viewGroup, false);
        }
        return new Holder(view, i);
    }

    /* renamed from: com.grass.lv.adapter.AdapterRecommend$Holder */
    public class Holder extends BaseRecyclerHolder {
        public ListVideoPlayer player;
        AppCompatRatingBar rating_bar;
        RelativeLayout rl_content;
        TextView tv_at;
        TextView tv_recommend;
        TextView tv_subtitle;
        TextView tv_title;
        public View video_mask;

        Holder(View view, int i) {
            super(view);
            if (i == 1) {
                this.tv_at = (TextView) view.findViewById(R.id.tv_at);
                return;
            }
            this.player = (ListVideoPlayer) view.findViewById(R.id.player);
            this.tv_title = (TextView) view.findViewById(R.id.tv_title);
            this.tv_recommend = (TextView) view.findViewById(R.id.tv_recommend);
            this.rating_bar = (AppCompatRatingBar) view.findViewById(R.id.rating_bar);
            view.findViewById(R.id.view).setOnClickListener(this);
            this.rl_content = (RelativeLayout) view.findViewById(R.id.rl_content);
            this.video_mask = view.findViewById(R.id.video_mask);
            ViewGroup.LayoutParams layoutParams = this.rl_content.getLayoutParams();
            layoutParams.height = (int) AdapterRecommend.this.height;
            this.rl_content.setLayoutParams(layoutParams);
            this.tv_subtitle = (TextView) view.findViewById(R.id.tv_subtitle);
        }

        public void setData(VideoBean videoBean, int i, int i2) {
            if (i2 == 1) {
                try {
                    String utcToChina1 = TimeUtils.utcToChina1(videoBean.getRecAt());
                    TextView textView = this.tv_at;
                    textView.setText("往期看點·" + utcToChina1);
                } catch (Exception e) {
                    e.printStackTrace();
                    this.tv_at.setText("往期看點");
                }
            } else {
                this.player.setVideoBean(videoBean, i, AdapterRecommend.this.playerVideoInterface);
                if (videoBean.getActress() == null || videoBean.getActress().size() <= 0) {
                    this.tv_title.setText("素人");
                } else {
                    this.tv_title.setText(videoBean.getActress().get(0).getActressName());
                }
                TextView textView2 = this.tv_recommend;
                textView2.setText("看点：" + videoBean.getReason());
                this.rating_bar.setRating(((float) videoBean.getRecScore()) / 2.0f);
                this.tv_subtitle.setVisibility(8);
                if (i == 0) {
                    if (AdapterRecommend.this.isPlay == 1) {
                        this.player.startPlayLogic();
                        AdapterRecommend.this.isPlay = 0;
                        AdapterRecommend.this.playerVideoInterface.click(this.player, videoBean, i);
                    }
                    this.video_mask.setVisibility(8);
                    return;
                }
                this.video_mask.setVisibility(0);
            }
        }
    }
}
